async function showModal(url, options, params) {
    let topWindow = top
    let dialogOptions = {
        width: 1000,
        height: 600,
        left: '2%',
        top: '2%',
        resizable: true,
        extStyle: ''
    }
    $.extend(dialogOptions, options);
    let pWidth = topWindow.innerWidth
    let pHeight = topWindow.innerHeight
    if (pWidth > dialogOptions.width) {
        dialogOptions.left = (pWidth - dialogOptions.width) / 2 + 'px'
    }
    if (pHeight > dialogOptions.height) {
        dialogOptions.top = (pHeight - dialogOptions.height) / 2 + 'px'
    }
    let styles = 'border-width: 1px;overflow: hidden;padding:0px;margin:0px;background:none;max-width:100%;max-height:100%;'
    styles = styles + 'width:' + dialogOptions.width + 'px;'
    styles = styles + 'height:' + dialogOptions.height + 'px;'
    styles = styles + 'top:' + dialogOptions.top + ';'
    styles = styles + 'left:' + dialogOptions.left + ';'
    styles = styles + dialogOptions.extStyle;
    let res = await top.showModalDialog(url, params, styles, dialogOptions.resizable);
    return res;
}

function closeModal() {
    let dialog = getCurDialog();
    dialog.close();
}
function getCurDialog() {
    let index = getDialogNumber() - 1;
    let dialog = top.document.getElementById('dialog' + index)
    return dialog
}
function getDialogNumber() {
    return top.document.getElementsByTagName('dialog').length
}
function getIdFromTop(id){
    return top.document.getElementById(id)
}